﻿#ifndef LOG_H
#define LOG_H

#include <string>

enum class log_level
{
    debug,
    info,
    warning,
    error
};

class logger
{
public:
    static logger& get_instance();

    void log(log_level level, const std::string& message, const char* file_name, int line_number);
    void set_log_file(const std::string& filename);
    void enable_console(bool enable);
    void enable_file(bool enable);

private:
    logger();
    ~logger() = default;

    std::string log_file_path;
    bool console_enabled;
    bool file_enabled;

    static std::string get_current_timestamp();
    static std::string get_level_string(log_level level);
    static std::string get_level_color(log_level level);
};

#define LOG(level, message) logger::get_instance().log(level, message, __FILE__, __LINE__)

#define LOG_DEBUD(message) logger::get_instance().log(log_level::debug, message, __FILE__, __LINE__)
#define LOG_INFO(message) logger::get_instance().log(log_level::info, message, __FILE__, __LINE__)
#define LOG_WARN(message) logger::get_instance().log(log_level::warning, message, __FILE__, __LINE__)
#define LOG_ERROR(message) logger::get_instance().log(log_level::error, message, __FILE__, __LINE__)

#endif
